<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
var numWaterBottles = function(numBottles, numExchange) {
    let count = numBottles
    while( numBottles >= numExchange ){
        let shang = Math.floor(numBottles / numExchange)
        count = count + shang
        let yu = numBottles % numExchange
        numBottles = shang + yu
    }
    return count
};

var numBottles = 15
var numExchange = 4
console.log(numWaterBottles(numBottles, numExchange))
    </script>
</body>
</html>